package es.decoroso.communicationAgent.bean;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.json.JSONException;
import org.json.JSONObject;

public class Vector2 {
	public float x,y;
	
	public Vector2(){
		this.x = 0f;
		this.y = 0f;
	}
	
	public Vector2(float x, float y) {
		this.x = x;
		this.y = y;
	}
	
	public Vector2(JSONObject js) {
		try {
			this.x = (float) js.getDouble("x");
			this.y = (float) js.getDouble("y");
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
	
	public JSONObject toJSON() {
        JSONObject js = new JSONObject();
        try {
            js.put("x", x);
            js.put("y", y);
        } catch (JSONException ex) {
            Logger.getLogger(Vector2.class.getName()).log(Level.SEVERE, null, ex);
        }
        return js;
    }

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}
	
}
